<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/my.js"></script>
</head>
<body>


<script>

    var num1 = window.prompt("请输入第一个数字")

    while (isNaN(num1)) {
        console.log("请输入数字")
        num1 = window.prompt("请输入第一个数字")
    }

    var operator = window.prompt("请输入运算符")

    var num2 = window.prompt("请输入第二个数字")

    while (isNaN(num2)) {
        console.log("请输入数字")
        num2 = window.prompt("请输入第二个数字")
    }


    var res;
    // 根据运算符 选择合适的函数   +  -  *  /
    switch (operator) {
        case '+':
            res = add(num1 * 1, num2 * 1)
            console.log(res)
            break;
        case '-':
            res = sub(num1, num2)
            console.log(res)
            break;
        case '*':
            res = mul(num1, num2)
            console.log(res)
            break;
        case '/':
            res = div(num1, num2)
            console.log(res)
            break;
        default:
            console.log("请输入正确的运算符！！")
            break;

    }


</script>
</body>
</html>